/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.rh.game.loader;

import java.util.ArrayList;
import java.util.List;

import com.rh.util.Parser;

/**
 *
 * @author hjones
 */
public class PreconditionBuffer extends AbstractXmlBuffer {
    private static void debug(Object o)  {
        // System.out.println("PreconditionBuffer: " + o);
    }
    
    public PreconditionBuffer()  {
        super();
        init();
    }

    private String type = "";
    private String whom = "";
    
    private List<GameConditionKeys> checks = null;
    public List<GameConditionKeys> getChecks()  {
        return checks;
    }
    
    void init()  {
        checks = new ArrayList<GameConditionKeys>();
        init2();
    }
    
    void init2()  {
        type = "";
        whom = "";
    }
    
    @Override
    void characters(String pValue) {
        debug(pValue);
        pValue = Parser.trim(pValue);
        if ("Type".equals(getStartElement()))  {
            type = pValue;
        }
        else if ("Whom".equals(getStartElement()))  {
            whom = pValue;
        }
    }

    @Override
    void endElement(String pName)  {
        if ("condition".equals(pName))  {
            GameConditionKeys gck = new GameConditionKeys();
            gck.setType(type);
            gck.setWhomID(whom);
            checks.add(gck);
            init2();
        }
    }
}
